package com.gxc.controller;

import com.gxc.service.SendMailService;
import com.gxc.utils.RestControllerResult;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * mail Controller.
 *
 * @author 宫新程
 * @since 2018/12/5 11:06 AM
 */
@RestController
@RequestMapping("/mail")
public class MailController {

  @Resource private SendMailService sendMailService;

  /** 发送邮件. */
  @RequestMapping("/send")
  public RestControllerResult<Boolean> sendMail() {
    return sendMailService.sendSimpleMail();
  }

  /** 用来测试全局异常处理. */
  @RequestMapping("/e/{num}")
  public RestControllerResult<Integer> testException(@PathVariable Integer num) {
    int i = 10 / num;
    RestControllerResult<Integer> result = new RestControllerResult<>();
    result.setData(i);
    result.setSuccess(true);
    return result;
  }
}
